/**
 * Created by z on 2017/5/17.
 */

function register() {

    var phoneNum = $("#phoneNum").val();
    var passwd = $("#passwd").val();
    var name = $("#name").val();
    var idNumber =  $("#idNumber").val();
    var recommendPhone = $("#recommendPhone").val();
    if(phoneNum==undefined || phoneNum==null ||phoneNum==''){
        $("#phoneNum").next('span').text("手机号不能为空");
        return false;
    }else{
        $("#phoneNum").next('span').text("");
    }
    if(passwd==undefined || passwd==null ||passwd==''){
        $("#passwd").next('span').text("密码不能为空");
        return false;
    }else{
        $("#passwd").next('span').text("");
    }
    if(name==undefined || name==null ||name==''){
        $("#name").next('span').text("姓名不能为空");
        return false;
    }else{
        $("#name").next('span').text("");
    }
    if(idNumber==undefined || idNumber==null ||idNumber==''){
        $("#idNumber").next('span').text("身份证不能为空");
        return false;
    }else{
        $("#name").next('span').text("");
    }
    // if(recommendPhone==undefined || recommendPhone==null ||recommendPhone==''){
    //     $("#recommendPhone").next('span')text("手机号不能为空");
    // }

    var paramJson = {};
    paramJson.phoneNum = phoneNum;
    paramJson.passwd = passwd;
    paramJson.name = name;
    paramJson.idNumber = idNumber;
    paramJson.recommendPhone = recommendPhone;

    $.ajax({
        type: "post",
        url: config.devUrl + "/user/register.json",
        data: paramJson,
        dataType: "json",
        success: function (data) {
            console.log(data);
            location.href = 'login.html';
        }
    });
}

